
package com.joysuch.wwyt.datadump.biz.model;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.zlg.common.datadump.annotation.DataDumpEntity;
import cn.zlg.common.datadump.annotation.DataDumpField;
import com.joysuch.wwyt.bp.entity.dsl.QBpDepart;
import com.joysuch.wwyt.datadump.biz.convertor.*;
import com.joysuch.wwyt.datadump.biz.processor.MhMonitorPointProcessor;
import com.joysuch.wwyt.datadump.biz.query.MhMonitorPointDumpQueryBean;
import com.joysuch.wwyt.mh.entity.dsl.QMhMonitoringPoint;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@DataDumpEntity(name = "mh-monitor-point-dump", entity = QMhMonitoringPoint.class, exportQueryConditions = MhMonitorPointDumpQueryBean.class,
        businessName = "监测点", batchDeleteField = "showState", deleteFlagValue = "0", importProcessors = MhMonitorPointProcessor.class)
@Data
public class MhMonitorPointDumpBean {

    @NotNull
    @Length(max = 64)
    @Excel(name = "监测点名称", width = 20)
    @DataDumpField(field = "name")
    private String name;

    @NotNull
    @Length(max = 64)
    @Excel(name = "监测点编号", width = 20)
    @DataDumpField(field = "pointCode", importKey = true)
    private String code;

    @NotNull
    @Excel(name = "责任部门名称", width = 20)
    @DataDumpField(field = "responsibleDept", referenceEntity = QBpDepart.class, referenceEntityField = "name")
    private String responsibleDeptName;

    @Excel(name = "上级责任部门名称", width = 20)
    @DataDumpField(field = "responsibleDept", referenceEntity = QBpDepart.class, referenceEntityField = "parentId", exportConvertors = {
            ExportGetDepartNameByIdConvertor.class }, importIgnore = true)
    private String parentResponsibleDeptName;

    @NotNull
    @Excel(name = "监测类型", width = 20)
    @DataDumpField(field = "mhMonitoringType", exportConvertors = ExportMonitorPointTypeUnitConvertor.class, importIgnore = true)
    private String monitoringTypeName;

    @NotNull
    @Excel(name = "地图独立显示", width = 20)
    // categoryId=1 => 环境监测点 => 是
    // categoryId=0 => 设备监测点 => 否
    @DataDumpField(field = "mhMonitoringType.categoryId", exportConvertors = ExportYesNoConvertor.class, importIgnore = true)
    private String showInMapIndependent;

    @Excel(name = "量程上限", width = 20)
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "请输入整数或小数,小数位最多6位，最大不超过±999999")
    @DataDumpField(field = "highValue")
    private String highValue;

    @Excel(name = "量程下限", width = 20)
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "请输入整数或小数,小数位最多6位，最大不超过±999999")
    @DataDumpField(field = "lowValue")
    private String lowValue;

    @Excel(name = "一级报警阈值(高位限)", width = 20)
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "请输入整数或小数,小数位最多6位，最大不超过±999999")
    @DataDumpField(field = "highValue1")
    private String highValue1;

    @Excel(name = "一级报警阈值(低位限)", width = 20)
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "请输入整数或小数,小数位最多6位，最大不超过±999999")
    @DataDumpField(field = "lowValue1")
    private String lowValue1;

    @Excel(name = "二级报警阈值(高高位限)", width = 20)
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "请输入整数或小数,小数位最多6位，最大不超过±999999")
    @DataDumpField(field = "highValue2")
    private String highValue2;

    @Excel(name = "二级报警阈值(低低位限)", width = 20)
    @Pattern(regexp = "^-?(?:\\d{1,6}(?:.\\d{1,6})?|\\d{1,3}(?:,\\d{3})*(?:.\\d{1,6})?)$", message = "请输入整数或小数,小数位最多6位，最大不超过±999999")
    @DataDumpField(field = "lowValue2")
    private String lowValue2;

    //开关
    @Excel(name = "监测点开关", width = 20)
    @DataDumpField(field = "state", exportConvertors = {ExportOpenShutConvertor.class}, importConvertors = ImportMhPointConvertor.class)
    private String state;
}
